package com.zbkj.admin.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.mybatisflex.annotation.*;
import com.zbkj.admin.handler.TimestampToLocalDateTimeTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.ibatis.type.JdbcType;

import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 用户层级关系 实体类。
 *
 * @author mybatis-flex-helper automatic generation
 * @since 1.0
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@TableRef(EbUserRelationshipEntity.class)
@Schema(name = "用户层级关系")
@TableName(value = "eb_user_relationship")
@Table(value = "eb_user_relationship")
public class EbUserRelationshipEntity implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @Schema(description = "主键")
    @Id(keyType = KeyType.Auto)
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 用户id
     */
    @Schema(description = "父级用户id")
    @Column(value = "uid")
    @TableField(value = "uid")
    private Long uid;

    /**
     * 父级用户id
     */
    @Schema(description = "父级用户id")
    @Column(value = "p_id")
    @TableField(value = "p_id")
    private Long pId;

    /**
     * 是否首单(0:是1:不是),目前未启用
     */
    @Schema(description = "是否首单(0:是1:不是),目前未启用")
    @Column(value = "is_first_order")
    @TableField(value = "is_first_order")
    private Integer isFirstOrder;

    /**
     * 团队
     */
    @Schema(description = "团队")
    @Column(value = "team")
    @TableField(value = "team")
    private Long team;

    /**
     * 0:临时关系，1:绑定(关系绑定)
     */
    @Schema(description = "0:临时关系，1:绑定(关系绑定)")
    @Column(value = "is_establish")
    @TableField(value = "is_establish")
    private Integer isEstablish = 0;

    /**
     * 创建时间
     */
    @Schema(description = "创建时间")
    @Column(value = "create_time", jdbcType = JdbcType.DATE, typeHandler = TimestampToLocalDateTimeTypeHandler.class)
    @TableField(value = "create_time", jdbcType = JdbcType.DATE, typeHandler = TimestampToLocalDateTimeTypeHandler.class)
    private LocalDateTime createTime;

    @Schema(description = "子集")
    @Column(ignore = true)
    @TableField(exist = false)
    private List<EbUserRelationshipEntity> subset;

    /**
     * 用户信息
     */
    @Schema(description = "用户信息")
    private EbUserEntity parent;

    /**
     * 成交金额
     */
    @Schema(description = "成交金额")
    @Column(ignore = true)
    private BigDecimal turnover;

    /**
     * 积分
     */
    @Schema(description = "积分")
    @Column(ignore = true)
    @TableField(exist = false)
    private BigDecimal points;
}
